/**
 * Created by Xuelei.kong on 2016/7/2.
 */
function showTime(){
    var show_day=new Array('星期一','星期二','星期三','星期四','星期五','星期六','星期日');
    var time=new Date();
    var year=time.getFullYear();
    var month=time.getMonth()+1;
    var date=time.getDate();
    var day=time.getDay();
    var hour=time.getHours();
    var minutes=time.getMinutes();
    var second=time.getSeconds();
    month=month<10?"0"+month:month;
    date=date<10?"0"+date:date;
    hour<10?hour='0'+hour:hour;
    minutes<10?minutes='0'+minutes:minutes;
    second<10?second='0'+second:second;
    var now_time= year+'年'+month+'月'+date+'日'+' '+show_day[day-1];
    var time=hour+':'+minutes+':'+second;
    document.getElementById('date').innerHTML=now_time;
    document.getElementById('time').innerHTML=time;
    setTimeout("showTime();",1000);
}
showTime();

// 指定图表的配置项和数据
optionDay = {
    color:[
        "#c23531","#ddd","#61a0a8","#d48265"
    ],
    textStyle:{
        fontSize:18,
    },
    backgroundColor:"#114855",
    title: {
        left:"50%",
        top:10,
        textAlign:"center",
        text: '日产量图',
        textStyle:{
            color:"#fff"
        }
    },
    tooltip : {
        trigger: 'axis'
    },
    legend: {
        data:['电','水','气','综'],
        right:'4%',
        top:'3%',
        textStyle:{
            color:"#fff"
        }
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    axisLabel : {
        show : true,
        textStyle : {
            color : '#fff'
        }
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : false,
            data : ['0','10','20','30','40','50','60','70','80','90','100'],
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    yAxis : [
        {
            type : 'value',
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    series : [
        {
            name:'电',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[120, 132, 101, 134, 90, 230, 210, 90, 230, 210, 90]
        },
        {
            name:'水',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[220, 182, 191, 234, 290, 330, 310, 90, 230, 210, 90]

        },
        {
            name:'气',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[150, 232, 201, 154, 190, 330, 410, 190, 330, 410,10]
        },
        {
            name:'综',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[320, 332, 301, 334, 390, 330, 320, 390, 330, 320,50]
        }

    ]
};
optionMonth = {
    color:[
        "#c23531","#ddd","#61a0a8","#d48265"
    ],
    textStyle:{
        fontSize:18,
    },
    backgroundColor:"#114855",
    title: {
        left:"50%",
        top:10,
        textAlign:"center",
        text: '月产量图',
        textStyle:{
            color:"#fff"
        }
    },
    tooltip : {
        trigger: 'axis'
    },
    legend: {
        data:['电','水','气','综'],
        right:'4%',
        top:'3%',
        textStyle:{
            color:"#fff"
        }
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    axisLabel : {
        show : true,
        textStyle : {
            color : '#fff'
        }
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : false,
            data : ['0','10','20','30','40','50','60','70','80','90','100'],
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    yAxis : [
        {
            type : 'value',
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    series : [
        {
            name:'电',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[120, 132, 101, 134, 90, 230, 210, 90, 230, 210, 90]
        },
        {
            name:'水',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[220, 182, 191, 300, 290, 330, 310, 90, 230, 210, 90]

        },
        {
            name:'气',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[150, 232, 201, 900, 190, 330, 410, 190, 330, 410,10]
        },
        {
            name:'综',
            type:'line',
            stack: '总量',
            // areaStyle: {normal: {}},
            data:[320, 332, 301, 334, 390, 330, 320, 390, 330, 320,50]
        }

    ]
};



optionEle = {
    backgroundColor:"#114855",
    color:[
        "#b04522","#5a823c","#036b87","#c9a814"
    ],
    title : {
        x:'center',
        left:"50%",
        top:20,
        textAlign:"center",
        text: '车间日用电量占比',
        textStyle:{
            color:"#fff"
        }
    },
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        left: 'left',
    },
    series : [
        {
            name: '电',
            type: 'pie',
            radius : '55%',
            center: ['50%', '60%'],
            data:[
                {value:335, name:'1'},
                {value:310, name:'2'},
                {value:234, name:'3'},
                {value:135, name:'4'},
            ],
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};
optionClt = {
    backgroundColor:"#114855",
    title : {
        x:'center',
        left:"50%",
        top:10,
        textAlign:"center",
        text: '产量图',
        textStyle:{
            color:"#fff"
        }
    },

    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },

    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            data : ['周一','周二','周三','周四','周五','周六','周日'],
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    yAxis : [
        {
            name:"Tce/Kpcs",
            type : 'value',
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    series : [
        {
            name:'直接访问',
            type:'bar',
            data:[320, 332, 301, 334, 390, 330, 320],

            itemStyle: {
                normal:{
                    color:"#42887d"
                },
                emphasis: {
                    color:"#42887d"
                }
            }
        }

    ]
};

optionDht = {
    backgroundColor:"#114855",
    title : {
        x:'center',
        left:"50%",
        top:10,
        textAlign:"center",
        text: '单耗图',
        textStyle:{
            color:"#fff"
        }
    },

    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },

    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            data : ['周一','周二','周三','周四','周五','周六','周日'],
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    yAxis : [
        {
            name:"Tce/Kpcs",
            type : 'value',
            axisLine:{
                lineStyle:{
                    color:"#fff",
                    width:2
                }
            }
        }
    ],
    series : [
        {
            name:'直接访问',
            type:'bar',
            data:[320, 332, 301, 334, 390, 330, 320],

            itemStyle: {
                normal:{
                    color:"#a62258"
                },
                emphasis: {
                    color:"#a62258"
                }
            }
        }

    ]
};
optionTotal = {
    backgroundColor:"#114855",
    color:[
        "#b04522","#5a823c","#036b87","#c9a814"
    ],
    title : {
        x:'center',
        left:"50%",
        top:10,
        textAlign:"center",
        text: '车间月用电量占比',
        textStyle:{
            color:"#fff"
        }
    },
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },

    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis:  {
        type: 'category',
        data: ['7月'],
        axisLine:{
            lineStyle:{
                color:"#fff",
                width:2
            }
        }

    },
    yAxis: {
        type: 'value',
        axisLine:{
            lineStyle:{
                color:"#fff",
                width:2
            }
        }
    },
    series: [
        {
            name: 'A',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [320]
        },
        {
            name: 'B',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [120]
        },
        {
            name: 'C',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [220]
        },
        {
            name: 'D',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [150]
        },
        {
            name: 'E',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [820]
        }
    ]
};

// 基于准备好的dom，初始化echarts实例
    if(document.getElementById('month')){
        var myChartDay = echarts.init(document.getElementById('day'));
        var myChartMonth = echarts.init(document.getElementById('month'));
// 使用刚指定的配置项和数据显示图表。
        myChartDay.setOption(optionDay);
        myChartMonth.setOption(optionMonth);
    }

if (document.getElementById('ele')) {
    var myChartEle = echarts.init(document.getElementById('ele'));
// 使用刚指定的配置项和数据显示图表。
    myChartEle.setOption(optionEle);
}


if(document.getElementById('clt')){
    var myChartClt = echarts.init(document.getElementById('clt'));
// 使用刚指定的配置项和数据显示图表。
    myChartClt.setOption(optionClt);
}

if(document.getElementById('dht')){
    var myChartDht = echarts.init(document.getElementById('dht'));
// 使用刚指定的配置项和数据显示图表。
    myChartDht.setOption(optionDht);
}

if(document.getElementById('total')){
    var myChartTotal = echarts.init(document.getElementById('total'));
// 使用刚指定的配置项和数据显示图表。
    myChartTotal.setOption(optionTotal);
}


